﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AsmShaderConverter
{
    internal class LoadBinShader
    {
        private static SharpDX.D3DCompiler.DisassemblyFlags flags;
        public static string LoadBin(string filename)
        {
            FileStream fs = new FileStream(filename, FileMode.Open);
            BinaryReader br = new BinaryReader(fs);

            byte[] byteArray = br.ReadBytes((int)br.BaseStream.Length);

            try
            {
                SharpDX.D3DCompiler.ShaderBytecode test = new SharpDX.D3DCompiler.ShaderBytecode(byteArray);
                flags = SharpDX.D3DCompiler.DisassemblyFlags.EnableDefaultValuePrints;

                return  test.Disassemble(flags, "// My Comment");
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
